<%@include file="/header/head.jsp"%>
<jsp:include page="/header/header.jsp">
	<jsp:param value="${entity.title}" name="title" />
</jsp:include>
<div id="content">


	<a href="<spring:url value='/' />"> Home </a> <br />
	<a href="<spring:url value='/post/edit' />?id=${entity.id}"> Edit
	Post </a> <br />
	<a href="<spring:url value='/post/delete' />?id=${entity.id}">
	Delete Post </a> <br />
	<a href="<c:url value='/j_spring_security_logout' />">Logout</a>

<table width="60%" border="1" cellspacing="0">

	<tr>
		<td><c:out value="${entity.title}" /></td>
	</tr>
	<tr>
		<td><c:out value="${entity.body}" /></td>
	</tr>
	<tr>
		<td>Created By:<c:out value="${entity.owner.userName}" /> On <c:out
			value="${entity.createdDate}" /></td>
	</tr>

</table>
<spring:url value='/files/save' var="fileSaveAction" /> <form:form
	commandName="file" action="${fileSaveAction}" method="post"
	enctype="multipart/form-data">
	<table border="0" cellspacing="0">
		<tr>
			<td><strong>File to upload</strong></td>
			<td><input type="file" name="filePath" /></td>
		</tr>
		<tr>
			<td><strong>Notes</strong></td>
			<td><form:textarea path="notes" /></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
			<td><input type="submit" name="submit" value="Add File" /></td>
		</tr>
	</table>
	<spring:bind path="post">
		<input type="hidden" name="${status.expression}" value="${entity.id}" />
	</spring:bind>
</form:form>


<table width="80%" border="1" cellspacing="0" cellpadding="5">
	<tr>
		<th width="4%">No</th>
		<th width="30%">Filename</th>
		<th width="30%">Notes</th>
		<th width="16%">Type</th>
		<th width="16%">Created Date</th>
		<th width="20%">&nbsp;</th>
	</tr>
	<c:choose>
		<c:when test="${entity.files != null}">
			<c:forEach var="file" items="${entity.files}" varStatus="counter">
				<tr>
					<td>${counter.index + 1}</td>
					<td>${file.filename}</td>
					<td>${file.notes}</td>
					<td>${file.type}</td>
					<td>${file.createdDate}</td>
					<td>
					<div align="center"><a
						href="<spring:url value='/files/download'/>?id=${file.id}">Download</a>
					/ <a
						href="<spring:url value='/files/delete'/>?id=${file.id}&deleteTarget=/post/show?id=${entity.id}">Delete</a></div>
					</td>
				</tr>
			</c:forEach>
		</c:when>
	</c:choose>
</table>
<spring:url value='/comment/save' var="commentSaveAction" /> <form:form
	commandName="comment" action="${commentSaveAction}" method="post">
	<table border="0" cellspacing="0">
		<tr>
			<td><form:textarea path="body" /></td>
		</tr>
		<tr>
			<td><input type="submit" name="submit" value="Comment" /></td>
		</tr>
	</table>
	<spring:bind path="owner">
		<input type="hidden" name="${status.expression}" value="${user.id}" />
	</spring:bind>
	<spring:bind path="post">
		<input type="hidden" name="${status.expression}" value="${entity.id}" />
	</spring:bind>
</form:form> Comments: <br />
<c:forEach var="comment" items="${entity.comments}">
	<div><c:out value="${comment.body}"></c:out><br />
	Created By:<c:out value="${comment.owner.userName}" /> On <c:out
		value="${comment.createdDate}" /></div>
	<br />
</c:forEach>

</div>

<%@include file="/footer/footer.jsp"%>